package com.zara.store.client.controller;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;

import com.zara.store.client.clientmodel.PalcModel;

import framework.clientmodel.Model;
import framework.controller.Controller;
import framework.view.View;

public class PalcController extends Controller {
	
	public PalcController(Model model, View view) {
		super(model, view);
	}
	
	public void queryPalcProductList() {
		PalcModel model = (PalcModel)getModel();
		model.queryPalcProductList();
	}

	public void queryAndAddProduct(String barcode) {
		PalcModel model = (PalcModel)getModel();
		model.queryAndAddProduct(barcode);
	}

	public void clearAll() {
		PalcModel model = (PalcModel)getModel();
		model.clearAll();
	}

	public void changeProductAmount(int rowIndex, String value) {
		try {
			Double.valueOf(value);
		} catch(NumberFormatException e) { //validacion
			return;
		}
		BigDecimal amount = new BigDecimal(value);
		PalcModel model = (PalcModel)getModel();
		model.changeProductAmount(rowIndex, amount);
	}

	public void createPalc(File file) throws IOException {
		PalcModel model = (PalcModel)getModel();
		model.createPalc(file);
	}

}
